home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBRECLAS.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  85 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbreclas.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <lseq.h>
  13.  
  14. /* local headers */
  15. #include "cbase_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      cbreclast - last cbase record
  20.  
  21. SYNOPSIS
  22.      #include <cbase.h>
  23.  
  24.      int cbreclast(cbp)
  25.      cbase_t *cbp;
  26.  
  27. DESCRIPTION
  28.      The cbreclast function positions the record cursor of cbase cbp
  29.      on the last record.
  30.  
  31.      cbreclast will fail if one or more of the following is true:
  32.  
  33.      [EINVAL]       cbp is not a valid cbase pointer.
  34.      [CBELOCK]      cbp is not locked.
  35.      [CBENOPEN]     cbp is not open.
  36.      [CBENREC]      cbp is empty.
  37.  
  38. SEE ALSO
  39.      cbreccnt, cbrecfirst, cbrecnext, cbrecprev.
  40.  
  41. DIAGNOSTICS
  42.      Upon successful completion, a value of 0 is returned.  Otherwise,
  43.      a value of -1 is returned, and errno set to indicate the error.
  44.  
  45. ------------------------------------------------------------------------------*/
  46. #ifdef AC_PROTO
  47. int cbreclast(cbase_t *cbp)
  48. #else
  49. int cbreclast(cbp)
  50. cbase_t *cbp;
  51. #endif
  52. {
  53.     /* validate arguments */
  54.     if (!cb_valid(cbp)) {
  55.         errno = EINVAL;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not open */
  60.     if (!(cbp->flags & CBOPEN)) {
  61.         errno = CBENOPEN;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if not locked */
  66.     if (!(cbp->flags & CBLOCKS)) {
  67.         errno = CBELOCK;
  68.         return -1;
  69.     }
  70.  
  71.     /* check if cbp is empty */
  72.     if (lsreccnt(cbp->lsp) == 0) {
  73.         errno = CBENREC;
  74.         return -1;
  75.     }
  76.  
  77.     /* set cursor to last record */
  78.     if (lslast(cbp->lsp) == -1) {
  79.         CBEPRINT;
  80.         return -1;
  81.     }
  82.  
  83.     return 0;
  84. }
  85.